xquery version "0.9-ml"

(:returns a text string that represents a JavaScript data object :)
(:apostrophes are replaced with %u2019 because *sometimes* the encoding does not stick in the XML DB :)

xs:string('[')
,

let $node := xdmp:get-request-field("node")
let $filter := xdmp:get-request-field("filter")
(:
let $node := "doc('jasonmonberg.xml')/jasonmonberg/portino/feeds/savedItems" 
let $filter := "http://slashdot.org/"
:)
for $value in xdmp:eval($node)/savedItem (:/item:)
	where $value/node()/node() =   $filter

	return 
	( xs:string("'"),  fn:replace(xdmp:quote($value/node()), "'", "%u2019"),  xs:string("',")) 
	
,
xs:string(']')